import dateOptions from "@/utils/date"; //引入date的渲染
import gift from "/src/api/gift"
import {findBrand} from "/src/api/brand"

let brand = {
    name: "index",
    data() {
        return {
            dateOptions,
            tableData: [],//数据信息
            batchIds:[],
            brandList: {},
            total:0,
            searchParams: {

                giftName:"",
                currentPage: 1,//当前页
                pageSize: 5,//每页显示条数
                startTime: '',//开始时间
                endTime: '',//结束时间
                brandId: ''//品牌名称
            }


        }
    },
    created() {//回调函数
        this.searchPage();
    },
    methods: {


        //时间框 选择时间
        chooseTime() {
            this.searchParams.startTime = this.dateOptions.startDate[0];
            this.searchParams.endTime = this.dateOptions.startDate[1];
        },
        async searchPage(){
            let response = await gift.findPage(this.searchParams);
            console.log(response);
            console.log(response.total);
            this.tableData = response.data;
            this.total = response.total;
        },
        resetForm() {
            this.searchParams.giftName="",
            this.searchParams.currentPage= 1,//当前页
            this.searchParams.pageSize= 5,//每页显示条数
            this.searchParams.startTime='',//开始时间
            this.searchParams.endTime= '',//结束时间
            this.searchParams.brandId=null

            this.searchPage();
        },
        showBatchDeleteDialog() {

        },
        selectChange(row) {
            console.log(row);
        },
        deleteById(){

        },
        async currentPageChange(row){

            // console.log(row)
            this.searchParams.currentPage = row;
            await this.searchPage();
        },
        async findAllBrand(){

            let response = await findBrand();
            this.brandList = response;


        },
        async selectBrandId(row){
            this.searchParams.brandId = row;
        }
    }


}

export default brand;